#include <iostream>
using namespace std;

int main()
{
	int n, m, ans = 0;
	cin >> n >> m;
	while (n) {
		if (n >= m) {
			ans += m;
			n -= m;
			++n;
		} else {
			ans += n;
			n = 0;
		}
		//cout << ans << ' ' << n << endl;
	}
	cout << ans << endl;
}
